package com.baidu.day02;

import java.io.File;

public class Demo10 {
    public static void main(String[] args) {
        File f = new File("C:\\Users\\DAJU\\Desktop\\新建文件夹 (2)");
        deleteALL(f);
        f.delete();

    }

    public static void deleteALL(File f) {

        File[] fArr = f.listFiles();
        for (int i = 0; i < fArr.length; i++) {
//            if (fArr[i].isFile()) {
//                fArr[i].delete();
//            } else {
//                deleteALL(fArr[i]);
//                fArr[i].delete();
           /* if (fArr[i].isDirectory()) {
                deleteALL(fArr[i]);
            }else {
                fArr[i].delete();
            }*/
            //增强for循环
            for (File file : fArr) {
                if (file.isDirectory()){
                    deleteALL(file);
                }else {
                    file.delete();
                }

            }




            }


        }


    }



